﻿namespace Home.Mvc
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Web;

    public static class ProductUploadHelper
    {
        public static string BuildResponseHtml(bool success, string runningHtmlId, string successHtmlId, string failureHtmlId)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(runningHtmlId));
            Debug.Assert(!string.IsNullOrWhiteSpace(successHtmlId));
            Debug.Assert(!string.IsNullOrWhiteSpace(failureHtmlId));

            var successHtml = success ? "visible" : "hidden";
            var failureHtml = success ? "hidden" : "visible";
            return string.Concat(
                "<script language='javascript' type='text/javascript'>",
                $"window.top.window.document.getElementById('{runningHtmlId}').style.visibility='hidden';",
                $"window.top.window.document.getElementById('{successHtmlId}').style.visibility='{successHtml}';",
                $"window.top.window.document.getElementById('{failureHtmlId}').style.visibility='{failureHtml}';",
                "</script>");
        }
    }
}